package com.gujia.rabbitmq.ps;

import com.gujia.rabbitmq.util.ConnectionUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class Sender {

    private static final String EXCHANGE_NAME="test_exchange_fanout";
    public static void main(String[] args) throws Exception{
        Connection connection = ConnectionUtils.getConnction();
        Channel channel = connection.createChannel();
        //声明交换机
        channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
        String msg ="hello ps2";
        channel.basicPublish(EXCHANGE_NAME,"",null,msg.getBytes());
        System.out.println("Sender:"+msg);
        channel.close();
        connection.close();
    }
}
